/**
 * Definition for a binary tree node.
 * function TreeNode(val) {
 *     this.val = val;
 *     this.left = this.right = null;
 * }
 */
/**
 * @param {TreeNode} root
 * @return {number[]}
 */
 var levelOrder = function(root) {
    if(!root){
        return []
    }
    let floor = [];
    let res = []
    floor.push(root);
    for(let i=0;i<floor.length;i++){
        if(floor[i].left) floor.push(floor[i].left)
        if(floor[i].right) floor.push(floor[i].right)
        res.push(floor[i].val)
    }
    return res;
};